package com.test.test.dto.common;

import java.io.Serializable;

public class PageParam<T> implements Serializable{
	private static final long serialVersionUID = -5843865673294386818L;
	private Integer userId;//当前操作用户id
	private String token;//token
	private Integer pageNum; // 查询页码
	private Integer pageSize; // 每页记录数
	protected T args; // 查询参数
	public PageParam() {
	}

	public PageParam(Integer pageNum, Integer pageSize) {
		super();
		this.pageNum = pageNum;
		this.pageSize = pageSize;
	}

	public PageParam(Integer pageNum, Integer pageSize, T args) {
		this(pageNum, pageSize);
		this.args = args;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public T getArgs() {
		return args;
	}

	public void setArgs(T args) {
		this.args = args;
	}

	/**
	 * 获取分页开始游标（limit start,pageSize）
	 * 
	 * @return
	 */
	public Integer getStart() {
		return (pageNum - 1) * pageSize;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("PageParam [userId=");
		builder.append(userId);
		builder.append(", token=");
		builder.append(token);
		builder.append(", pageNum=");
		builder.append(pageNum);
		builder.append(", pageSize=");
		builder.append(pageSize);
		builder.append(", args=");
		builder.append(args);
		builder.append("]");
		return builder.toString();
	}
}
